#
# learn web: https://www.runoob.com/html/html5-draganddrop.html
#
#


from flask import Flask, request, jsonify, render_template

app = Flask(__name__)

# 模拟用户数据
users = {
    "admin": "1"
}

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/login', methods=['POST'])
def login():
    print("res:" ,request.data)
    
    username = request.json['username']
    password = request.json['password']
    
    print(f"Received login request for user: {username}")
    
    if username in users and users[username] == password:
        #return render_template('home.html')
        return jsonify({"success": True, "message": "登录成功"})
    else:
        return jsonify({"success": False, "message": "用户名或密码错误"})

@app.route('/home')
def home():
    return render_template('home.html')

@app.route('/boke')
def boke():
    return render_template('boke.html')

@app.route('/learn01')
def learn01():
    return render_template('learn01.html',title='learn01')

if __name__ == '__main__':
    app.run(debug=True)